package com.swh;

import org.junit.Test;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Set;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/12/24 18:00
 * @Version: 1.0
 */
public class test {
    @Test
   public void test01(){
        Jedis jedis = new Jedis("localhost");
        jedis.auth("123456");
        System.out.println("连接redis服务端成功！");

//        System.out.println("redis服务器正在运行吗？"+jedis.ping());
//        System.out.println("redis服务器信息？"+jedis.info());

//        jedis.set("key1", "name");
//        jedis.set("key2","pass");
//        String key1 = jedis.get("key1");
//        String key2 = jedis.get("key2");
//        System.out.println(key1);
//        System.out.println(key2);
        jedis.del("key1","key2","list1");


        Set<String> keys = jedis.keys("*");
        for (String key : keys) {
            System.out.println(key);
        }

    }

    @Test
    public void testList(){
        Jedis jedis = new Jedis("localhost");
        jedis.auth("123456");

//        jedis.lpush("list01", "a2", "a1","a3","a4");

        String list01 = jedis.lindex("list01", 0);
        System.out.println(list01);

        List<String> list011 = jedis.lrange("list01", 0, 8);
        for (String s : list011) {
            System.out.println(s);
        }
    }

}
